package redis

import (
	"fmt"
	"github.com/go-redis/redis"
	"goods_srv/appconfig"
)

var (
	err    error
	Client *redis.Client
)

func InItRedis() {
	app := appconfig.AppConf.InItRedis
	stu := fmt.Sprintf("%s:%d", app.Addr, app.Pars)
	Client = redis.NewClient(&redis.Options{
		Addr:     stu,
		Password: "", // no password set
		DB:       0,  // use default DB
	})

	_, err = Client.Ping().Result()
	fmt.Println(err)
	// Output: PONG <nil>
	if err != nil {
		fmt.Println("redis 连接失败")
		return
	}
	fmt.Println("redis 连接成功")
}
